package day01;

/**
 * @author feng
 * @Date 2021/10/14 11:29
 * 懒汉模式(静态内部类下加载)
 * 线程安全，静态内部类并不会立即执行，在调用的时候才会进行类的装载
 */
public class StaticSingleton {
    public static void main(String[] args) {
        System.out.println(SingletonTest04.getInstance01());
    }
}

class SingletonTest04 {

    private SingletonTest04() {
    }

    private static volatile SingletonTest04 singleton;

    //静态内部类
    public static class SingletonInstance {
        private static final SingletonTest04 INSTANCE = new SingletonTest04();
    }

    public static synchronized SingletonTest04 getInstance01(){
          return SingletonInstance.INSTANCE;

    }


}